-
-
Notifications
You must be signed in to change notification settings - Fork 404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow and handle non-parameters in rasterize.instance() #5811
Conversation
Codecov Report
@@ Coverage Diff @@
## main #5811 +/- ##
==========================================
+ Coverage 88.17% 88.22% +0.04%
==========================================
Files 307 307
Lines 62908 62983 +75
==========================================
+ Hits 55471 55565 +94
+ Misses 7437 7418 -19
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 9 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This is a MRE: import holoviews as hv
import numpy as np
import pandas as pd
from holoviews.operation.datashader import rasterize
hv.extension("bokeh")
df = pd.DataFrame(
np.random.multivariate_normal((0, 0), [[0.1, 0.1], [0.1, 1.0]], (500000,))
)
df.columns = ["a", "b"]
curve = hv.Curve(df, kdims=["a"], vdims=["b"])
inst = rasterize.instance(line_width=2)
hv.operation.apply_when(curve, operation=inst, predicate=lambda x: len(x) > 1000)
Is it possible to add a small unit test? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some comments, but maybe it is correct behavior to error out here.
When using .instance()
and one of the inputs is not a parameter (here line_width
), it is not using it. Beforehand this will just silently fail, but with the recent changes, it gives an error, which I'm leaning toward being a good thing.
Take a look at these examples (with your changes / the behavior before #5767):
import holoviews as hv
import numpy as np
import pandas as pd
from holoviews.operation.datashader import rasterize
hv.extension("bokeh")
np.random.seed(10)
df = pd.DataFrame(
np.random.multivariate_normal((0, 0), [[0.1, 0.1], [0.1, 1.0]], (500000,)),
columns=["a", "b"],
)
curve = hv.Curve(df, kdims=["a"], vdims=["b"])
rasterize.instance(line_width=2)(curve).opts(xlim=(1.1, 1.2), ylim=(1.1, 1.2))
rasterize(curve, line_width=2).opts(xlim=(1.1, 1.2), ylim=(1.1, 1.2))
So maybe in the hvplot
code, we should use a partial function for the operation:
hv.operation.apply_when(curve, operation=partial(rasterize, line_width=2), predicate=lambda x: len(x) > 1000)
Looks great, thanks! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I don't fully understand this...
If I use HoloViews alone / try to reproduce with HoloViews:
It runs fine...
However, if I use hvplot with this PR:
I get the following traceback: